
/*
import '../../../../core/app_export.dart';
import '../../../../widgets/app_bar/appbar_subtitle.dart';
import '../../../../widgets/app_bar/custom_app_bar.dart';
import '../../../../widgets/app_bar/outline_icon_button.dart';
import '../../../../widgets/custom_search_view.dart';
import '../../../../widgets/screen_state_widget.dart';
import '../../players/add_player_page/bloc/add_player_page_screen.dart';
import '../widgets/player_list_item_view.dart';
import 'all_players_cubit.dart';
import 'package:flutter/material.dart';

class SelectOrAddPlayerPage extends StatelessWidget {
  const SelectOrAddPlayerPage({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    double height = MediaQuery.of(context).size.height;
    double width = MediaQuery.of(context).size.width;

    return BlocProvider<PlayersTabCubit>(
      create: (context) => PlayersTabCubit()..getAllUsers(),
      child: BlocConsumer<PlayersTabCubit, PlayersTabState>(
        listener: (context, state) {
          // TODO: implement listener
        },
        builder: (context, state) {
          var cubit = PlayersTabCubit.get(context);

          return Scaffold(
            appBar: _buildAppBar(context: context, cubit: cubit),
            body: Container(
              height: height,
              width: width,
              decoration: BoxDecoration(
                image: DecorationImage(
                  image: AssetImage(ImageConstant.imgBackground),
                  fit: BoxFit.cover,
                ),
              ),
              child: Column(
                children: [
                  Padding(
                    padding: const EdgeInsets.all(8.0),
                    child: Row(
                      children: [
                        Expanded(
                          child: CustomSearchView(
                            controller: cubit.searchBox,
                            hintText: 'ادخل اسم او رقم اللاعب',
                            onChanged: (value) {
                              cubit.onSearch(value);
                            },
                            onClear: () {
                              cubit.onSearch('');
                            },
                          ),
                        ),
                        SizedBox(width: 8),
                        OutlineIconButton(
                          icon: Icons.add,
                          margin: const EdgeInsets.all(8),
                          padding: const EdgeInsets.all(2),
                          onTapped: () async {
                            await Navigator.push(
                              context,
                              MaterialPageRoute(builder: (context) => const AddPlayerPageScreen()),
                            ).then((value) {
                              //cubit.getAllUsers();
                            });
                          },
                        ),
                      ],
                    ),
                  ),
                  Expanded(
                    child: ScreenStateWidget(
                      isDone: state is PlayersTabDone,
                      isError: state is PlayersTabError,
                      isLoading: state is PlayersTabLoading,
                      onRefresh: cubit.getAllUsers,
                      onDone: GridView.builder(
                        gridDelegate: const SliverGridDelegateWithMaxCrossAxisExtent(
                            maxCrossAxisExtent: 100,
                            mainAxisExtent: 120
                        ),
                        itemCount: cubit.users.length,
                        itemBuilder: (context, index) {
                          return PlayerItemView(user: cubit.users[index]);
                        },
                      ),
                    ),
                  ),
                ],
              ),
            ),
          );
        },
      ),
    );
  }

  PreferredSizeWidget _buildAppBar({required BuildContext context, required PlayersTabCubit cubit}) {
    return CustomAppBar(
      leadingWidth: 120,
      leading: Row(
        children: [
          OutlineIconButton(
            imagePath: ImageConstant.imgRightIcon,
            onTapped: () {
              Navigator.pop(context);
            },
          ),
        ],
      ),
      title: AppbarSubtitle(text: 'اختر او اضف لاعب جديد'),
    );
  }
}*/
